home *** CD-ROM | disk | FTP | other *** search
- Path: detroit.freenet.org!ab411
- From: ab411@detroit.freenet.org (David R. Conrad)
- Newsgroups: comp.lang.c
- Subject: Re: "Best fit" algorithm (help)
- Date: 29 Mar 1996 15:58:54 GMT
- Organization: Greater Detroit Free-Net, Detroit, MI
- Message-ID: <4jh1bu$rro@detroit.freenet.org>
- References: <APC&7'0'22b6b83'874@peg.apc.org>
- Reply-To: ab411@detroit.freenet.org (David R. Conrad)
- NNTP-Posting-Host: detroit.freenet.org
-
-
- In a previous article, riox@peg.apc.org () says:
- >I am looking for a "best fit" algorithm.
- >The problem I have is very similar to finding the best way of fitting the
- >maximum number of songs on (say) 45 minute tape.
- >If one knows the length of each song and the number of songs, how can one
- >find the best arrangement to occupy maximum amount of tape without "cutting"
- >off any songs. Ie, how to minimise the empty space left on the tape.
-
- This should probably be posted to comp.sci.algorithms, not comp.lang.c.
-
- This is the knapsack problem, and if I recall correctly it is NP-complete.
- To find the best (optimal) fit, I think there is no known solution better
- than trying all possible arrangements of songs (no pun intended).
-
- To find a good fit, I think a good algorithm would be to assign the longest
- songs to tapes first, then smaller songs, until you reach the smallest.
-
- --
- David R. Conrad, conrad@detroit.freenet.org : PGP key on : GDFN Hardware and
- http://www.freenet.org/staff/conrad/ : home page : Software Committee
- Union of Computer Hackers, : Is a tune greater than the hum of its parts?
- Local 2^859433-1 APL-CPIO : Is Twain more than the Sam of his parts?
-